#ifndef _PARSE_LOC
#define _PARSE_LOC

#include <string>
#include "Buffer.h"
#include <map>
#include "Bitset.h"

namespace parse_code {
	class Err_input {};
	class Err_copy {};
	class Err_open {};

	struct Code_pos {
		int start;
		int end;
	};
	typedef std::map<std::string, Code_pos> Item_code;
	void copycode(mylib::Buffer &from, std::ostream &to, const char *end_sign=0);	// throw exception if match error
	Code_pos get_usr_data_pos(mylib::Buffer &from);						// get user data definition position, if exist
	Code_pos get_end_code_pos(mylib::Buffer &from);						// get end code position
	void write_next_token(mylib::Buffer &from, std::ostream &out, std::string &ret_type, Code_pos *usr_data=0);
	void write_next_token_left(mylib::Buffer &from, std::ostream &out, Code_pos *end_code=0);
	void action_code(mylib::Buffer &from, std::ostream &to,int dfa_num, const Item_code &codes);
	Code_pos item_code(mylib::Buffer &from);			// handle new item's code
	void write_static_code(std::ostream &out);
	void write_data_init(std::istream &in, std::ostream &out,int dfa_num);	// write data and init function
}
#endif
